package codetop.kuaishou.T82;

import util.ListNode;

/**
 * @Author: 18362
 * @Create: 2022-09-14 17:18:06 星期三
 */
class Solution {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode dummy = new ListNode(0, head), i = dummy;
        while (i.next != null) {
            ListNode j = i.next.next;
            boolean flag = false;
            while (j != null && j.val == i.next.val) {
                j = j.next;
                flag = true;
            }
            if (flag)
                i.next = j;
            else
                i = i.next;
        }
        return dummy.next;
    }
}